package com.vcredit.creditcat.manager;

import com.alibaba.dubbo.config.annotation.Service;
import com.vcredit.creditcat.api.IAppCacheClearManager;
import com.vcredit.creditcat.api.IAppSwitchManager;
import com.vcredit.creditcat.service.AppSwitchService;
import com.vcredit.creditcat.service.CardConditionService;
import com.vcredit.creditcat.service.ProductConditionService;
import com.vcredit.creditcat.service.speedloan.ProcessSpecialItemService;
import com.vcredit.creditcat.service.speedloan.ProcessSpecialService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * APP部分缓存请求统一处理类
 *
 * @author wichell
 */
@Service(protocol = { "protocol1" }, version = "1.0")
public class AppCacheClearManager implements IAppCacheClearManager {

	@Autowired
	private ProductConditionService productConditionService;

	@Autowired
	private CardConditionService cardConditionService;

	@Autowired
	private ProcessSpecialItemService processSpecialItemService;

	@Autowired
	private ProcessSpecialService processSpecialService;

	/**
	 * 根据入参清除缓存
	 *
	 * @param cacheType speedloan:快贷流程的缓存数据 condition：产品列表和办卡的缓存数据
	 */
	@Override
	public void clearCache(String cacheType) {
		switch (cacheType) {
			case "speedloan":{
				processSpecialItemService.clearProcessSpecialItemsCache();
				processSpecialService.clearProcessSpecialsCache();
				break;
			}
			case "condition":{
				productConditionService.clearProductConditionCache();
				cardConditionService.clearcardConditionCache();
				break;
			}
			default:
			{
				productConditionService.clearProductConditionCache();
				cardConditionService.clearcardConditionCache();
				break;
			}
		}
	}
}
